package sxe.core.math;

import snobject.snDouble;
import snobject.snObject;
import snobject.snObjectArgList;
import step.FunctionWrapper;
import step.EvaluationFailure;

/**
 * Returns the largest (closest to positive infinity) double value that is not greater than the argument and is equal to a mathematical integer.
 * @param argv must contain an snDouble object at top of the stack
 * @return returns the snDouble value of the largest (closest to positive infinity) value that is not greater than the argument and is equal to a integer
 */

public class floor extends FunctionWrapper{
	
	public snObject Call(snObjectArgList argv) throws EvaluationFailure{
		// REQUIRES: argv must contain an snDouble object at top of the stack
		// EFFECTS: returns the snDouble value of the largest (closest to negative infinity) value that is not greater than the argument and is equal to a an integer
		double ret = argv.popDouble().getDbl();
		
		return new snDouble(Math.floor(ret));
	}
}